package hot100;

import DTO.TreeNode;

public class isSymmetric {

    boolean cur = true;

    public boolean isSymmetric(TreeNode root) {
        if(root.left == null && root.right == null) {
            return cur;
        }
        retcur(root.left,root.right);
        return cur;
    }

    public void retcur(TreeNode left,TreeNode right) {
        if(cur == false) {
            return;
        }
        if(left == null && right == null) {
            cur = true;
            return;
        }
        if(left == null && right != null) {
            cur = false;
            return;
        }
        if(left != null && right == null) {
            cur = false;
            return;
        }
        if(left.val != right.val) {
            cur = false;
            return;
        }

        retcur(left.left,right.right);
        retcur(left.right,right.left);
        return;
    }
}
